@import '../../theme/mixins/mixins.scss';
@import '../../theme/default.scss';

%normal-shadow {
  box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14),
    0 1px 5px 0 rgba(0, 0, 0, 0.12);
  &:active {
    box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14),
      0 3px 14px 2px rgba(0, 0, 0, 0.12);
  }
}

%fab-shadow {
  box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14),
    0 1px 18px 0 rgba(0, 0, 0, 0.12);
}

@mixin contained-circle-round-colors {
  @include m(default) {
    color: $--color-black;
    background-color: $--color-gray;
  }
  @include m(primary) {
    background-color: $--color-primary;
  }
  @include m(secondary) {
    background-color: $--color-secondary;
  }
  @include m(success) {
    background-color: $--color-success;
  }
  @include m(warning) {
    background-color: $--color-warning;
  }
  @include m(danger) {
    background-color: $--color-danger;
  }
}

@include b(btn) {
  display: inline-block;
  height: 36px;
  padding: 0 15px;
  font-weight: 400;
  font-size: 14px;
  line-height: $line-height-base;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  @include when(disabled) {
    color: $--color-disabled;
    box-shadow: none;
    cursor: not-allowed;
  }

  @include m(small) {
    height: 24px;
    padding: 0 7px;
    font-size: 12px;
    border-radius: 4px;
    [class*='-icon'] {
      font-size: 12px;
    }
    [class*='-icon'].material-icons {
      font-size: 16px;
    }
    &[class*='__circle'],
    &[class*='__icon'] {
      width: 24px;
      height: 24px;
      padding: 0;
      font-size: 14px;
    }
  }

  @include m(large) {
    height: 40px;
    padding: 0 15px;
    font-size: 16px;
    border-radius: 4px;
    [class*='-icon'].material-icons {
      font-size: 34px;
    }
    &[class*='__circle'],
    &[class*='__icon'] {
      width: 56px;
      height: 56px;
      padding: 0;
      font-size: 18px;
    }
  }

  @include e(loading) {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 99;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: $--color-primary;
    background-color: rgba($--color-white, 0.5);
    border-radius: inherit;
  }

  @include e(wrapper) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
  }

  @include e(contained) {
    color: $--color-white;
    @extend %normal-shadow;
    @include contained-circle-round-colors;
    @include when(disabled) {
      background-color: $--button-disable-background;
    }
  }

  @include e(text) {
    background-color: transparent;
    @media (hover: none) {
      &:hover {
        background-color: transparent !important;
      }
    }
    @include when(disabled) {
      &:hover {
        background-color: transparent;
      }
    }
    @include m(default) {
      color: $--color-black;
      &:hover {
        background-color: rgba($--color-black, 0.05);
      }
    }
    @include m(primary) {
      color: $--color-primary;
      &:hover {
        background-color: rgba($--color-primary, 0.1);
      }
    }
    @include m(secondary) {
      color: $--color-secondary;
      &:hover {
        background-color: rgba($--color-secondary, 0.1);
      }
    }
    @include m(success) {
      color: $--color-success;
      &:hover {
        background-color: rgba($--color-success, 0.1);
      }
    }
    @include m(warning) {
      color: $--color-warning;
      &:hover {
        background-color: rgba($--color-warning, 0.1);
      }
    }
    @include m(danger) {
      color: $--color-danger;
      &:hover {
        background-color: rgba($--color-danger, 0.1);
      }
    }
  }

  @include e(outlined) {
    background-color: transparent;
    @media (hover: none) {
      &:hover {
        background-color: transparent !important;
      }
    }
    @include when(disabled) {
      border-color: $--button-disable-background;
      &:hover {
        background-color: transparent;
      }
    }
    @include m(default) {
      color: $--color-black;
      border: 1px solid rgba($--color-black, 0.26);
      &:hover {
        background-color: rgba($--color-black, 0.05);
      }
    }
    @include m(primary) {
      color: $--color-primary;
      border: 1px solid rgba($--color-primary, 0.5);
      &:hover {
        background-color: rgba($--color-primary, 0.1);
      }
    }
    @include m(secondary) {
      color: $--color-secondary;
      border: 1px solid rgba($--color-secondary, 0.5);
      &:hover {
        background-color: rgba($--color-secondary, 0.1);
      }
    }
    @include m(success) {
      color: $--color-success;
      border: 1px solid rgba($--color-success, 0.5);
      &:hover {
        background-color: rgba($--color-success, 0.1);
      }
    }
    @include m(warning) {
      color: $--color-warning;
      border: 1px solid rgba($--color-warning, 0.5);
      &:hover {
        background-color: rgba($--color-warning, 0.1);
      }
    }
    @include m(danger) {
      color: $--color-danger;
      border: 1px solid rgba($--color-danger, 0.5);
      &:hover {
        background-color: rgba($--color-danger, 0.1);
      }
    }
  }

  @include e(circle) {
    width: 40px;
    height: 40px;
    padding: 0;
    color: $--color-white;
    border-radius: 50%;
    @extend %normal-shadow;
    @include contained-circle-round-colors;
    @include when(disabled) {
      background-color: $--button-disable-background;
    }
  }

  @include e(round) {
    color: $--color-white;
    border-radius: 36px;
    @extend %normal-shadow;
    @include contained-circle-round-colors;
    @include when(disabled) {
      background-color: $--button-disable-background;
    }
  }

  @include e(icon) {
    width: 40px;
    height: 40px;
    padding: 0;
    overflow: hidden;
    background-color: transparent;
    border-radius: 50%;
    @media (hover: none) {
      &:hover {
        background-color: transparent !important;
      }
    }
    @include when(disabled) {
      &:hover {
        background-color: transparent;
      }
    }
    @include m(default) {
      color: $--color-black;
      &:hover {
        background-color: rgba($--color-black, 0.05);
      }
    }
    @include m(primary) {
      color: $--color-primary;
      &:hover {
        background-color: rgba($--color-primary, 0.1);
      }
    }
    @include m(secondary) {
      color: $--color-secondary;
      &:hover {
        background-color: rgba($--color-secondary, 0.1);
      }
    }
    @include m(success) {
      color: $--color-success;
      &:hover {
        background-color: rgba($--color-success, 0.1);
      }
    }
    @include m(warning) {
      color: $--color-warning;
      &:hover {
        background-color: rgba($--color-warning, 0.1);
      }
    }
    @include m(danger) {
      color: $--color-danger;
      &:hover {
        background-color: rgba($--color-danger, 0.1);
      }
    }
  }

  @include m(fab) {
    @extend %fab-shadow;
  }
}
